/**
 * 
 */
package webreg.model.swing;

import java.awt.Component;

import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JTree;
import javax.swing.tree.DefaultTreeCellRenderer;

import webreg.model.Athlet;
import webreg.model.Competition;
import webreg.model.Disciplin;

/**
 * @author STKNOLL
 * 
 */
public class CompetitionTreeCellRenderer extends DefaultTreeCellRenderer {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Icon mCompetitionIcon;
	private Icon mAthletIcon;
	private Icon mDisciplinIcon;

	/**
	 * 
	 */
	public CompetitionTreeCellRenderer() {
		mCompetitionIcon = new ImageIcon();
		mAthletIcon = new ImageIcon();
		mDisciplinIcon = new ImageIcon();
	}

	public Component getTreeCellRendererComponent(JTree tree, Object value,
			boolean sel, boolean expanded, boolean leaf, int row,
			boolean hasFocus) 
	{
		super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf,
				row, hasFocus);
		
		if (value instanceof Competition) {
			setIcon(mCompetitionIcon);
			setToolTipText("Name der Veranstaltung.");
		} else if (value instanceof Athlet) {
			setIcon(mAthletIcon);
			setToolTipText("Name des Athleten.");
		} else if (value instanceof Disciplin) {
			setIcon(mDisciplinIcon);
			setToolTipText("Name der Disciplin.");
		} else {
			setToolTipText(null); // no tool tip
		}

		return this;
	}

}
